package com.nightpiter.controller.algorithms;

import java.util.LinkedList;

import com.nightpiter.model.objects.Station;
import com.nightpiter.model.objects.Transition;

/**
 * Route class for Dijkstra's Algorithm
 * 
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */
public class Route extends Way {
	/**
	 * transitions to pass throw
	 */
	private LinkedList<Transition> transitions;

	/**
	 * route ends
	 */
	private Station fromStation, toStation;

	/**
	 * constructs empty route
	 */
	public Route() {
		super();
		this.transitions = new LinkedList<Transition>();
	}

	/**
	 * @param other
	 */
	Route(Way way, Vertex fromVertex, Vertex toVertex) {
		super(way);
		this.transitions = new LinkedList<Transition>();
		int pass = way.transferHops;
		Edge edge = way.getEdge();
		while (edge != null) {
			Transition transition = edge.getTransition();
			this.transitions.add(transition);
			if (edge.transferHops != 0) {
				pass--;
			}
			edge = edge.fromVertex.passWayMap.get(pass).getEdge();
		}
		this.fromStation = fromVertex.getStation();
		this.toStation = toVertex.getStation();
	}

	public Station getFromStation() {
		return fromStation;
	}

	public Station getToStation() {
		return toStation;
	}

	public LinkedList<Transition> getTransitions() {
		return transitions;
	}

	/**
	 * @return total distance including tunnels and transfers
	 */
	public int getTotalDistance() {
		return tunnelDistance + transferDistance;
	}

	/**
	 * @return the tunnelDistance
	 */
	public int getTunnelDistance() {
		return tunnelDistance;
	}

	/**
	 * @return the tunnelHops
	 */
	public int getTunnelHops() {
		return tunnelHops;
	}

	/**
	 * @return the transferDistance
	 */
	public int getTransferDistance() {
		return transferDistance;
	}

	/**
	 * @return the transferHops
	 */
	public int getTransferHops() {
		return transferHops;
	}

}
